// First Chart Example - Area Line Chart
$(function(){
	if($("#morris-chart-area"))
	{
		$.ajax({
			type:'post',
			url:'admin_action.php',
			data:{type:'user_chart'},
			dataType:'json',
			success:function(data)
			{
				if(data.status==1)
				{
					Morris.Area({
						// ID of the element in which to draw the chart.
						element: 'morris-chart-area',
						// Chart data records -- each entry in this array corresponds to a point on
						// the chart.
						data:data.item.list,
						// The name of the data record attribute that contains x-visitss.
						xkey: 'd',
						// A list of names of data record attributes that contain y-visitss.
						ykeys: ['visits'],
						// Labels for the ykeys -- will be displayed when you hover over the
						// chart.
                        labels: ['Register'],
						// Disables line smoothing
						smooth: false
					});
					$("#user_info_time").html(data.item.start_time+' - '+data.item.end_time);
				}
				else
				{
					$("#morris-chart-area").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'+data.msg+'</div>');
				}
			},
			error:function()
			{
				$("#morris-chart-area").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>网络异常</div>');
			}
		});
	}
	if($("#morris-chart-donut"))
	{
		$.ajax({
			type:'post',
			url:'admin_action.php',
			data:{type:'artice_chart'},
			dataType:'json',
			success:function(data)
			{
				if(data.status==1)
				{
					Morris.Donut({
						element: 'morris-chart-donut',
						data: data.item.list,
						formatter: function (y) { return y + "%" ;}
					});
					$("#article_info_time").html(data.item.start_time+' - '+data.item.end_time);
				}
				else
				{
					$("#morris-chart-donut").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'+data.msg+'</div>');
				}
			},
			error:function()
			{
				$("#morris-chart-donut").html('<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>网络异常</div>');
			}
		});
	}
});
